package com.ruoyi.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.CzTaskEquipmentUser;
import com.ruoyi.business.service.ICzTaskEquipmentUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务人员设备关联Controller
 * 
 * @author ruoyi
 * @date 2022-01-09
 */
@Api(tags = "任务人员设备关联")
@RestController
@RequestMapping("/business/task_equipment_user")
public class CzTaskEquipmentUserController extends BaseController
{
    @Autowired
    private ICzTaskEquipmentUserService czTaskEquipmentUserService;

    /**
     * 查询任务人员设备关联列表
     */
    @ApiOperation(value = "查询任务人员设备关联列表")
    @PreAuthorize("@ss.hasPermi('business:task_equipment_user:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzTaskEquipmentUser czTaskEquipmentUser)
    {
        startPage();
        List<CzTaskEquipmentUser> list = czTaskEquipmentUserService.selectCzTaskEquipmentUserList(czTaskEquipmentUser);
        return getDataTable(list);
    }

    /**
     * 导出任务人员设备关联列表
     */
    @ApiOperation(value = "导出任务人员设备关联列表")
    @PreAuthorize("@ss.hasPermi('business:task_equipment_user:export')")
    @Log(title = "任务人员设备关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzTaskEquipmentUser czTaskEquipmentUser)
    {
        List<CzTaskEquipmentUser> list = czTaskEquipmentUserService.selectCzTaskEquipmentUserList(czTaskEquipmentUser);
        ExcelUtil<CzTaskEquipmentUser> util = new ExcelUtil<CzTaskEquipmentUser>(CzTaskEquipmentUser.class);
        util.exportExcel(response, list, "任务人员设备关联数据");
    }

    /**
     * 获取任务人员设备关联详细信息
     */
    @ApiOperation(value = "获取任务人员设备关联详细信息")
    @PreAuthorize("@ss.hasPermi('business:task_equipment_user:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(czTaskEquipmentUserService.selectCzTaskEquipmentUserById(id));
    }

    /**
     * 新增任务人员设备关联
     */
    @ApiOperation(value = "新增任务人员设备关联")
    @PreAuthorize("@ss.hasPermi('business:task_equipment_user:add')")
    @Log(title = "任务人员设备关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzTaskEquipmentUser czTaskEquipmentUser)
    {
        return toAjax(czTaskEquipmentUserService.insertCzTaskEquipmentUser(czTaskEquipmentUser));
    }

    /**
     * 修改任务人员设备关联
     */
    @ApiOperation(value = "修改任务人员设备关联")
    @PreAuthorize("@ss.hasPermi('business:task_equipment_user:edit')")
    @Log(title = "任务人员设备关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzTaskEquipmentUser czTaskEquipmentUser)
    {
        return toAjax(czTaskEquipmentUserService.updateCzTaskEquipmentUser(czTaskEquipmentUser));
    }

    /**
     * 删除任务人员设备关联
     */
    @ApiOperation(value = "删除任务人员设备关联")
    @PreAuthorize("@ss.hasPermi('business:task_equipment_user:remove')")
    @Log(title = "任务人员设备关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(czTaskEquipmentUserService.deleteCzTaskEquipmentUserByIds(ids));
    }
}
